/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import dao.ActivityHistoryCrud;
import dao.LiveServersDao;
import dao.ProviderDao;
import pojo.LiveServers;
import pojo.Provider;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Vector;
import pojo.ActivityHistory;

/**
 *
 * @author Mostafa
 */
public class Query {
    
    
    public Vector<Provider> getByProvider(Connection c,String searchtext) throws SQLException
    {

                  ProviderDao pdao=new ProviderDao(c);
                  Vector<Provider> result=pdao.getByPattern(searchtext);
                 return result;
    
       
    }
    
    public Vector<String> getProviders(Connection c) throws SQLException
    {
    
       
           
//                String url ="jdbc:mysql://localhost:3306/dimensionproject";
//              
//                  DriverManager.registerDriver(new com.mysql.jdbc.Driver() );
//                  Connection c=DriverManager.getConnection(url, "root", "root");
                  ProviderDao pdao=new ProviderDao(c);
                  Vector<String> result=pdao.getAllProviders();
                 return result;
    
       
    }
 //get Activities by Date   
    public Vector<ActivityHistory> getByDate(Connection c,java.sql.Date date,String operator)
    {
         try 
         {              
            return  new ActivityHistoryCrud(c).getByActivityTime(date,operator);
         } 
         catch (Exception ex) 
         {
            Logger.getLogger(ActivityHistoryCrud.class.getName()).log(Level.SEVERE, null, ex);
         }
         return null; 
    }
//Get All Live Servers That Match That Name
    public Vector<LiveServers> getByLiveServerName(Connection connection, String searchtext) 
    {
                LiveServersDao lsdao=new LiveServersDao(connection);
                Vector<LiveServers> result=lsdao.getByPattern(searchtext);
                return result;
    }
//Get All Live Servers History In Specific Date
    public Vector<ActivityHistory> getLiveServerByDate(Connection connection, java.sql.Date date, String operator) 
    {
        try 
        {
            return  new ActivityHistoryCrud(connection).getLiveServerHistoryByTime(date,operator);
        } 
        catch (Exception ex) 
        {
            Logger.getLogger(ActivityHistoryCrud.class.getName()).log(Level.SEVERE, null, ex);
        }
      return null; 
    }
}
